#include<bits/stdc++.h>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    
    while (m--) {
        int x;
        cin >> x;
        auto left = lower_bound(arr.begin(), arr.end(), x);
        auto right = upper_bound(arr.begin(), arr.end(), x);
        //只需检查左边：如果左边界都不等于x，那么右边界的前一个位置也不可能等于x
        if (left != arr.end() && *left == x) {
            cout << left - arr.begin() << " " << right - arr.begin() - 1 << endl;
        } else {
            cout << "-1 -1" << endl;
        }
    }
    return 0;
}





























